<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../../jQuery-JS/jquery-3.6.0.js"></script>
    <script type="text/javascript">
        $(function(){
            //1.$.each():遍历数组或对象中的数据
            //遍历数组
            var arr1=[1,2,3,4,5,6,7];
            $.each(arr1,function(index,number){
                console.log("Item#"+index+":"+number); 
            })
            //遍历对象
            var obj1=
            {
                name:"Tom",
                age:18,
                gender:"Man"
            }
            $.each(obj1,function(index,number){
                console.log("obj1."+index+":"+number); 
            })
            
            //2.$.trim():去除字符串两边的空格
            var str="   asd   ";
            console.log($.trim(str));

            //3.$.type(obj):得到数据的类型
            var a=12;
            var arr2=[1,2,3,4];
            var obj2=
            {
                name:"Jack",
                age:21,
                gender:"Man"
            };
            console.log($.type(a),$.type(arr2),$.type(obj2));

            //4.$.isArray(obj):判断是否是数组
            console.log($.isArray(a),$.isArray(arr2),$.isArray(obj2));

            //5.$.isFunction(obj):判断是否是函数
            var fun1=function()
            {
                var a=3;
                console.log(a);
            };
            console.log($.isFunction(a),$.isFunction(arr2),$.isFunction(obj2),$.isFunction(fun1));
        
            //6.$.parseJSON(json):解析json字符串转换为js对象/数组
            var json='{"name":"Tom","age":18,"gender":"Man"}';
            console.log(json);
            console.log($.parseJSON(json));
        })
    </script>
</head>
<body>
    <!--
        1.$.each():遍历数组或对象中的数据
        2.$.trim():去除字符串两边的空格
        3.$.type(obj):得到数据的类型
        4.$.isArray(obj):判断是否是数组
        5.$.isFunction(obj):判断是否是函数
        6.$.parseJSON(json):解析json字符串转换为js对象/数组
    -->
</body>
</html>